home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
comm
/
tcp
/
rxsocket.lha
/
rxsocket
/
Examples
/
gsm.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-05-29
|
2KB
|
80 lines
/* */
l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
prg=ProgramName("NOEXT")
if AddLibrary("rexxsupport.library","rxsocket.library")~=0 then call err "can't find" result,1
if ~RMH_ReadArgs("PREFS/A,TEL/A,TEXT/A/F") then do
call PrintFault(IoErr(),prg)
exit
end
s=socket("INET","STREAM")
if s<0 then call err "can't create socket"
say "Resolving host name..."
sin.addraddr=resolve("www.mtn.co.za")
if sin.addraddr=-1 then call err "Host not found ("hosterrorstring(hosterrorno())")",1
sin.addrport=80
say "Connecting..."
if connect(s,"SIN")<0 then call err "can't connect"
call err "Sending request..."
arg="intlPrefix="code(parm.0.value)"&TEL="code(parm.1.value)"&Message="code(parm.2.value)
fin="d0a"x
post=,
"POST http://www.mtn.co.za/send/sms-rich.html HTTP/1.0"fin||,
"User-Agent: Amiga-AWeb/3.1"fin||,
"Accept: */*;q=1"fin||,
"Host: www.mtn.co.za"fin||,
"Referer: http://www.mtn.co.za/sms/secure/text.html"fin||,
"Content-Length:"length(arg)||fin||,
"Content-Type: application/x-www-form-urlencoded"fin||fin
if send(s,post)<0 then call err "error sending"
if send(s,arg)<0 then call err "error sending"
say "Receiving results..."
res=recvline(s,"BUF",256)
if res>0 then do
parse var buf "HTTP/1.1 "code error"A"x
if code~=200 then call err "server error" error "("code")",1
end
do while res>0
if left(buf,3)="<P>" & left(right(buf,5),4)="</P>" then do
parse var buf "<P>"buf"<"
parse var buf buf"."
leave
end
res=recvline(s,"BUF",256)
end
if res<0 then call err "error receiving"
else do
if pos("HTML",buf)~=0 then buf="Sorry, the message was not sent"
say buf
end
exit
/**************************************************************************/
code: procedure
parse arg t
res=""
do i=1 to length(t)
c=substr(t,i,1)
if (c<'0') | (c>'z') then c="%"c2x(c)
res=res||c
end
return res
/**************************************************************************/
err:
parse arg msg,noerr
if noerr~=1 then es="("ErrorString(Errno())")"
else es=""
say prg": "msg es
exit
/**************************************************************************/